package com.task.web.controller.core;

import javax.annotation.Resource;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.task.common.core.controller.BaseController;
import com.task.common.core.domain.AjaxResult;
import com.task.core.dto.request.SysSettingModifyRequestDTO;
import com.task.core.dto.request.SysSettingRequestDTO;
import com.task.core.service.SysSettingService;

import io.swagger.annotations.ApiModelProperty;

/**
 * @author 迪迦.
 * @date 2025/2/10 11:20
 */
@RestController
@RequestMapping("/systemSetting")
public class SysSettingController extends BaseController {

  @Resource
  private SysSettingService sysSettingService;

  @ApiModelProperty("查询所有系统设置表system_settings的分组信息")
  @PreAuthorize("@ss.hasPermi('systemSetting:list')")
  @GetMapping("/getAllSetting")
  public AjaxResult getAllSetting(SysSettingRequestDTO request) {
    return success(sysSettingService.getAllSetting(request));
  }

  @ApiModelProperty("修改系统设置表system_settings的分组信息")
  @PutMapping("/modifySettingByCode")
  public AjaxResult modifySettingByCode(@RequestBody SysSettingModifyRequestDTO request) {
    sysSettingService.modifySettingByCode(request);
    return success();
  }

  @ApiModelProperty("根据类型获取设置")
  @GetMapping("/getSettingByType")
  public AjaxResult getSettingByType(SysSettingRequestDTO request) {
    return success(sysSettingService.getSettingByType(request));
  }

  @ApiModelProperty("根据类型和键获取设置")
  @GetMapping("/getSettingByTypeAndKey")
  public AjaxResult getSettingByTypeAndKey(SysSettingRequestDTO request) {
    return success(sysSettingService.getSettingByTypeAndKey(request));
  }

}
